/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-08-03
 * Time: 9:06
 * To BE A Better Person-2020-3-2
 */
public class TestDemo3 {
    public static  Object locker1=new Object();
    public static  Object locker2=new Object();
    public static  Object locker3=new Object();

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 10; i++) {
            Thread a=new Thread(()->{
               synchronized (locker1){
                   try {
                       locker1.wait();
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
                System.out.println("A");
               synchronized (locker2){
                   locker2.notify();
               }

            });
            Thread b=new Thread(()->{
                synchronized (locker2){
                    try {
                        locker2.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("B");
                synchronized (locker3){
                    locker3.notify();
                }

            });
            Thread c=new Thread(()->{
                synchronized (locker3){
                    try {
                        locker3
                                .wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("C");

            });
            a.start();
            b.start();
            c.start();
            Thread.sleep(1000);
            synchronized (locker1){
                locker1.notify();
            }

        }
    }
}
